package com.gaoaoy.finance.admin.api.controller;

import com.gaoao.common.dto.ApiResponse;
import com.gaoaoy.finance.biz.service.MemberLoginService;
import com.gaoaoy.finance.biz.service.dto.form.GetBase64CodeForm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gaoaoy
 * @version 1.0.0
 * @create 2024/3/24 17:01
 **/

@Api(tags = "用户登录模块")
@RestController
@RequestMapping(value = "/login")
@RequiredArgsConstructor
@Slf4j
public class LoginController {

    final MemberLoginService memberLoginService;

    /**
     * 获取客户端ID
     *
     * @return 客户端ID
     */
    @ApiOperation(value = "获取客户端ID")
    @GetMapping(value = "/getClientId")
    public ApiResponse<String> getClientId() {
        String result = memberLoginService.getClientId();
        return ApiResponse.success(result);
    }

    /**
     * 获取图形验证码
     *
     * @return 验证码
     */
    @ApiOperation(value = "获取图形验证码")
    @GetMapping(value = "/getBase64Code")
    public ApiResponse<String> getBase64Code(@Validated @ModelAttribute GetBase64CodeForm form) {
        String code = memberLoginService.getBase64Code(form);
        return ApiResponse.success(code);
    }
}
